using System;
using System.Collections.Generic;

namespace K3Cloud.WebApi.Core.IoC.K3Client
{
    /// <summary>
    /// K3Cloud错误日志记录接口
    /// 用于记录K3Cloud API调用过程中的错误信息
    /// </summary>
    public interface IK3ErrorLogger
    {
        /// <summary>
        /// 记录错误日志
        /// </summary>
        /// <param name="message">错误消息</param>
        /// <param name="exception">异常对象（可选）</param>
        /// <param name="context">错误上下文信息（可选）</param>
        void LogError(string message, Exception? exception = null, Dictionary<string, object>? context = null);

        /// <summary>
        /// 记录K3 API调用错误
        /// </summary>
        /// <param name="apiName">API名称（如：ExecuteBillQuery, Save等）</param>
        /// <param name="formId">单据FormId</param>
        /// <param name="errorMessage">错误消息</param>
        /// <param name="exception">异常对象</param>
        void LogApiError(string apiName, string formId, string errorMessage, Exception? exception = null);

        /// <summary>
        /// 记录查询错误
        /// </summary>
        /// <param name="entityType">实体类型</param>
        /// <param name="queryJson">查询JSON（可选，用于诊断）</param>
        /// <param name="errorMessage">错误消息</param>
        /// <param name="exception">异常对象</param>
        void LogQueryError(string entityType, string? queryJson, string errorMessage, Exception? exception = null);

        /// <summary>
        /// 记录数据保存错误
        /// </summary>
        /// <param name="formId">单据FormId</param>
        /// <param name="dataJson">保存的数据JSON（可选）</param>
        /// <param name="errorMessage">错误消息</param>
        /// <param name="exception">异常对象</param>
        void LogSaveError(string formId, string? dataJson, string errorMessage, Exception? exception = null);

        /// <summary>
        /// 记录批量操作错误
        /// </summary>
        /// <param name="operation">操作类型（如：BatchSave, BatchDelete）</param>
        /// <param name="formId">单据FormId</param>
        /// <param name="affectedCount">影响的记录数</param>
        /// <param name="errorMessage">错误消息</param>
        /// <param name="exception">异常对象</param>
        void LogBatchError(string operation, string formId, int affectedCount, string errorMessage, Exception? exception = null);

        /// <summary>
        /// 记录缓存操作错误
        /// </summary>
        /// <param name="cacheKey">缓存键</param>
        /// <param name="operation">操作类型（Get/Set/Remove）</param>
        /// <param name="errorMessage">错误消息</param>
        /// <param name="exception">异常对象</param>
        void LogCacheError(string cacheKey, string operation, string errorMessage, Exception? exception = null);
    }
}
